package com.haruhinav.controller;

import com.haruhinav.entity.Message;
import com.haruhinav.entity.vo.ReplyMsgVO;
import com.haruhinav.entity.extend.MessageEX;
import com.haruhinav.service.MessageService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/api/msg")
public class MessageController {

    @Resource
    private MessageService messageService;

    @PostMapping("/e/insert")
    public boolean insertMsg(@RequestBody Message message){
        return messageService.insertMsg(message);
    }
//    回复
    @PostMapping("/e/reply")
    public boolean replyMsg(@RequestBody ReplyMsgVO replyMsg){

        return messageService.replyMsg(replyMsg);
    }
    @GetMapping("/e/all")
    public Map<String,Object> getAllMsg(@RequestParam("page") Integer page,
                                        @RequestParam("size") Integer size){
        MessageEX messageEX = new MessageEX();
        messageEX.setPage(page);
        messageEX.setPageSize(size);
        return messageService.getAllMsg(messageEX);
    }
}
